TW.IDE.Widgets.hikvision = function () {

	this.widgetIconUrl = function() {
		return  "'../Common/extensions/ThingXExts/ui/hikvision/hikvisionIco.png'";
	};

	this.widgetProperties = function () {
		return {
			'name': 'Hikvision',
			'description': '海康威视摄像头',
			'category': ['Common'],
			'isExtension':true,
	        'supportsAutoResize': true,
			'properties': {
				'ProtocolType': {
					'description' : 'http/https',
					'baseType': 'INTEGER',
                    'isVisible': true,
                    'isEditable': true,
					'isBindingTarget': true,
					'defaultValue': 1,
					 'selectOptions': [{ value:1, text: 'http' },
				                        { value:2, text: 'https' }]
				     
		            },
                'IP': {
                    'description': 'IP Address',
                    'isVisible': true,
                    'isEditable': true,
                    'isBindingTarget': true,
                    'baseType': 'STRING'
                },
                'Port': {
                    'description': 'Camera Port',
                    'isVisible': true,
                    'isEditable': true,
                    'isBindingTarget': true,
                    'baseType': 'INTEGER',
                    'defaultValue': 80
                },
                'UserName': {
                    'description': 'Camera UserName',
                    'isVisible': true,
                    'isEditable': true,
                    'isBindingTarget': true,
                    'baseType': 'STRING'
                },
                'Password': {
                    'description': 'Camera Password',
                    'isVisible': true,
                    'isEditable': true,
                    'isBindingTarget': true,
                    'baseType': 'STRING'
                },
                'IStreamType': {
                    'description': 'Camera  Bit Stream Type',
                    'isVisible': true,
                    'isEditable': true,
                    'isBindingTarget': true,
                    'baseType': 'INTEGER',
                    'defaultValue': 1
                },
                'IChannelID': {
                    'description': 'Camera Channel',
                    'isVisible': true,
                    'isEditable': true,
                    'isBindingTarget': true,
                    'baseType': 'INTEGER',
                    'defaultValue': 1
                },
                'Width': {
                    'description': 'Widget width',
                    'defaultValue': 400
                },
                'Height': {
                    'description': 'Widget height',
                    'defaultValue': 300
                }
			}
		}
	};

	this.afterSetProperty = function (name, value) {
		var thisWidget = this;
		var refreshHtml = false;
		switch (name) {
			case 'ProtocolType':
				thisWidget.jqElement.find('ProtocolType').text(value);
				refreshHtml = true;
				break;
			case 'IP':
				thisWidget.jqElement.find('IP').text(value);
				refreshHtml = true;
				break;
			case 'Port':
				thisWidget.jqElement.find('Port').text(value);
				refreshHtml = true;
				break;
			case 'UserName':
				thisWidget.jqElement.find('UserName').text(value);
				refreshHtml = true;
				break;
			case 'Password':
				thisWidget.jqElement.find('Password').text(value);
				refreshHtml = true;
				break;
			case 'IStreamType':
				thisWidget.jqElement.find('IStreamType').text(value);
				refreshHtml = true;
				break;
			case 'IChannelID':
				thisWidget.jqElement.find('IChannelID').text(value);
				refreshHtml = true;
				break;
			case 'Width':
				thisWidget.jqElement.find('Width').text(value);
				refreshHtml = true;
				break;
			case 'Height':
				thisWidget.jqElement.find('Height').text(value);
				refreshHtml = true;
				break;
			default:
				break;
		}
		return refreshHtml;
	};

	this.renderHtml = function () {
		// return any HTML you want rendered for your widget
		// If you want it to change depending on properties that the user
		// has set, you can use this.getProperty(propertyName).
		return 	'<div class="widget-content widget-hikvisioncamera">' +
		 '<img width="100%" height="100%" src="../Common/extensions/ThingXExts/ui/hikvision/hikvisionImg.png">'+
	'</div>';
	};

	this.afterRender = function () {
		// NOTE: this.jqElement is the jquery reference to your html dom element
		// 		 that was returned in renderHtml()

		// get a reference to the value element
		valueElem = this.jqElement.find('.hikvision-property');
		// update that DOM element based on the property value that the user set
		// in the mashup builder
		valueElem.text(this.getProperty('Hikvision Property'));
	};

};